import {_decorator, EventTouch, NodeEventType} from 'cc';
import {BaseComponent} from "db://assets/scripts/framework/BaseComponent";
import {MessageCenter} from "db://assets/scripts/framework/MessageCenter";
import {MessageType} from "db://assets/scripts/framework/MessageType";

const {ccclass, property} = _decorator;

@ccclass('PlayerController')
export class PlayerController extends BaseComponent {
    start() {
        this.node.on(NodeEventType.TOUCH_START, (event: EventTouch) => {
            this.changeHP(-10);
        });
    }

    update(deltaTime: number) {

    }

    changeHP(hp: number) {
        // 发送消息
        MessageCenter.sendCustomMessage(MessageType.TYPE_UI, MessageType.UI_REFRESH_HP, hp);
    }
}

